// Generate a two-color caret for any element.
@mixin double-caret($background: var(--bgColor-default, var(--color-canvas-default)), $border: var(--borderColor-default, var(--color-border-default))) {
  &::after,
  &::before {
    position: absolute;
    // stylelint-disable-next-line primer/spacing
    top: 11px;
    right: 100%;
    left: calc(var(--base-size-8) * -1);
    display: block;
    width: 8px;
    height: 16px;
    pointer-events: none;
    content: ' ';
    clip-path: polygon(0 50%, 100% 0, 100% 100%);
  }

  &::after {
    // stylelint-disable-next-line primer/spacing
    margin-left: 2px;
    background-color: var(--bgColor-default, var(--color-canvas-default));
    background-image: linear-gradient($background, $background);
  }

  &::before {
    // stylelint-disable-next-line primer/colors
    background-color: $border;
  }
}

// global focus styles

// inset box-shadow for form controls
@mixin focusBoxShadowInset($outlineWidth: 1px, $outlineColor: var(--focus-outlineColor, var(--color-accent-fg))) {
  // stylelint-disable-next-line primer/colors
  border-color: var(--focus-outlineColor, var(--color-accent-fg));
  outline: none;
  // stylelint-disable-next-line primer/box-shadow
  box-shadow: inset 0 0 0 $outlineWidth $outlineColor;
}

// box-shadow for :target styles (no inset)
// !important to override PCSS utilities
@mixin targetBoxShadow($outlineWidth: 2px, $outlineColor: var(--focus-outlineColor, var(--color-accent-fg))) {
  outline: none !important;
  // stylelint-disable-next-line primer/box-shadow
  box-shadow: 0 0 0 $outlineWidth $outlineColor !important;
}

// outline
@mixin focusOutline($outlineOffset: -2px, $outlineColor: var(--focus-outlineColor, var(--color-accent-fg))) {
  outline: 2px solid $outlineColor;
  outline-offset: $outlineOffset;
  box-shadow: none;
}

// outline with fg box-shadow for buttons
@mixin focusOutlineOnEmphasis($outlineOffset: -2px, $outlineColor: var(--focus-outlineColor, var(--color-accent-fg))) {
  outline: 2px solid $outlineColor;
  outline-offset: $outlineOffset;
  // stylelint-disable-next-line primer/box-shadow
  box-shadow: inset 0 0 0 3px var(--fgColor-onEmphasis, var(--color-fg-on-emphasis));
}

// if min-width is undefined, return only min-height
@mixin minTouchTarget($min-height: 32px, $min-width: '') {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100%;
  height: 100%;
  min-height: $min-height;
  content: '';
  transform: translateX(-50%) translateY(-50%);

  @if $min-width != '' {
    min-width: $min-width;
  }
}
